<!DOCTYPE html>
<html lang="en">
<head>
    <title>其他支出</title>
    <#include "../inc/header.ftl"/>
    <link rel="stylesheet" href="${prefix}/assets/custom/css/main.css" />
</head>

<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">

            <div class="page-content">
                <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="r_tablebr">
                    <tr>
                        <td class="r_nr">
                            <table width="99%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td class="r_title">河北省非税收入其他转出资金</td>
                                </tr>
                            </table>
                            <form name="ChargeBillHandForm" id="ChargeBillHandForm" action="ChargeBillHandData" method="post">
                                <table width="99%" border="0" cellpadding="0" cellspacing="0" class="r_zsdwbm">
                                    <input name="ischeck" type="hidden" id="ischeck" value=""/>
                                    <input name="ishave1" type="hidden" id="ishave1" value="false"/>
                                    <input name="ishave2" type="hidden" id="ishave2" value="false"/>
                                    <input name="ishave3" type="hidden" id="ishave3" value="false"/>
                                    <input name="eticketnum" type="hidden" id="eticketnum" value=""/>
                                    <input name="vertifycode" type="hidden" id="vertifycode" value=""/>
                                    <input name="isscale" type="hidden" id="isscale" value=""/>
                                    <tr>
                                        <td>行政区划编码：
                                            <input name="cantoncode" type="text" id="cantoncode"/>
                                        </td>
                                        <td align="center" width="20%">&nbsp;</td>
                                        <td>交易流水号&nbsp;&nbsp;<input type="text" id="bankaffirm" name="bankaffirm" value="" class="r_input2" style="width:90px;"></td>
                                    </tr>
                                    <tr>
                                        <td>付款单位编码：
                                            <input name="unitcode" type="text" id="unitcode" value="" class="" />
                                        </td>
                                        <td align="center" width="20%">&nbsp;</td>
                                        <td>交易日期&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="paybankdt" name="paybankdt" class="easyui-datebox" style="width:100px"></td>
                                    </tr>
                                    <tr>
                                        <td width="40%">付款单位名称：
                                            <input name="unitname" type="text" readonly="readonly" id="unitname"  value="" class="r_input3" /></td>
                                        <td align="center"  width="20%">&nbsp;</td>
                                        <td align="right"  width="40%">&nbsp;</td>
                                    </tr>
                                </table>
                                <table width="99%" border="1" cellpadding="0" cellspacing="1" class="r_jcxx2">
                                    <tr>
                                        <td width="15%" align="right">收款人全称</td>
                                        <td width="35%"><input name="payer" type="text" id="payer" class="" style="width:95%;background:#ffffff" value="" /></td>
                                        <td width="15%" align="right">付款人全称</td>
                                        <td><input name="payee" type="text" id="payee" style="width:95%" value="" /></td>

                                    </tr>
                                    <tr>
                                        <td align="right">收款人账号</td>
                                        <td><input type="text" name="payeraccount" id="payeraccount" value="" class="" style="width:95%;background:#ffffff" /></td>
                                        <td width="15%" align="right">付款人账号</td>
                                        <td><input name="payeeaccount" type="text" readonly="readonly" id="payeeaccount" style="width:95%" value="" /></td>
                                    </tr>

                                </table>
                                <table width="99%" border="1" cellpadding="0" cellspacing="1" class="r_jcxx3" id="tab">
                                    <tr>
                                        <td width="30%" align="center" >编码</td>
                                        <td width="25%" align="center">&nbsp;</td>
                                        <td width="45%" align="center">收入项目</td>
                                    </tr>
                                    <tr id="tab-tr1">
                                        <td align="center"><input name="itemcode" id="itemcode" style="border: 0;" type="text"  value="" /></td>
                                        <td><input type="button" name="btnUnitVsItem1" id="btnUnitVsItem1" hidden class="r_button2" value="X" onclick="openfwfcz()"/></td>
                                        <td><input name="itemname" readonly="true" id="itemname" readonly="true" style="border: 0;"/></td>

                                    </tr>
                                </table>
                                <table width="99%" border="0" cellpadding="0" cellspacing="0" class="r_zsdwbm">

                                    <tr>
                                        <td align="right">金额（大写）：
                                            <input name="bigoriginfund" type="text" id="bigoriginfund" class="r_input" readonly="readonly" style="width:250px" value="" />
                                            （小写）：
                                            <input name="originfund" type="text" id="originfund" class=""  style="width:80px;height:20px" value="" onchange="fundchange()"/></td>
                                    </tr>
                                    <tr>
                                        <td align="right">用途说明：
                                            <input name="postscript" type="text" id="postscript" class="r_input2"  style="width:350px" value="" />
                                        </td>
                                    </tr>
                                </table>
                            </form>
                            <table width="99%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td height="40" align="right">
                                        <input type="button" name="paybutton" id="paybutton"  class="r_button" onclick="pay()" value="付款" />
                                        <input type="button" name="button3" id="button3"  class="r_button" value="关闭" />
                                    </td>
                                </tr>
                            </table></td>
                    </tr>
                </table>
            </div><!-- /.page-content -->

        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<!-- basic scripts -->
<#include "../inc/basicjs.ftl"/>
<script src="${prefix}/assets/custom/js/commonview.js"></script>

<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function(){
        var curr_time = new Date();
        var str = curr_time.getFullYear()+"-";
        str += curr_time.getMonth()+1+"-";
        str += curr_time.getDate()+"-";
        $('#paybankdt').datebox('setValue',str);
    });

    //---区划三级下拉框
    $('#cantoncode').combotree({
        url:prefix+'/base/basedata/findUserCantonMap',
        required: true,
        width: 200
    });
    $('#cantoncode').combo({
        onChange: function(){
            var t = $('#cantoncode').combotree('tree');	// get the tree object
            var n = t.tree('getSelected');
            $('#unitcode').combogrid({
                panelWidth:520,
                panelMaxHeight: 150,
                idField:'unitid',
                textField:'unitcode',
                url:prefix+'/base/basedata/findUnitTwo',
                queryParams: {cantonid:n.id},
                columns:[[
                    {field:'unitid',title:'ID',width:80},
                    {field:'unitcode',title:'单位编码',width:160},
                    {field:'unitname',title:'单位名称',width:260}
                ]],
            });

        }
    })

    $('#unitcode').combogrid({
        onChange: function(){
            var g = $('#unitcode').combogrid('grid');	// get datagrid object
            var r = g.datagrid('getSelected');
            $('#unitname').val(r.unitname);
            var t = $('#cantoncode').combotree('tree');	// get the tree object
            var n = t.tree('getSelected');
            $('#payee').combogrid({
                panelMaxHeight: 150,
                panelWidth:510,
                idField:'accountcode',
                textField:'bankname',
                url: prefix+'/base/basedata/findBankVoView',
                queryParams: {cantonid:n.id},
                columns:[[
                    {field:'accountcode',title:'收款人账号',width:80},
                    {field:'accountname',title:'收款人全称',width:160},
                    {field:'bankname',title:'收款人开户银行',width:260}
                ]],
            });
            $('#itemcode').combogrid({
                panelWidth:240,
                panelMaxHeight: 150,
                idField:'itemcode',
                textField:'itemcode',
                url:prefix+'/base/basedata/findUnitVsItemView',
                queryParams: {unitid:r.unitid},
                columns:[[
                    {field:'itemcode',title:'编号',width:80},
                    {field:'itemname',title:'名称',width:160}
                ]],
            });
        }
    })
    $('#payee').combogrid({
        onChange: function(){
            var g = $('#payee').combogrid('grid');	// get datagrid object
            var r = g.datagrid('getSelected');	// get the selected row
            $('#payeeaccount').val(r.accountcode);
        }
    })
    $('#itemcode').combogrid({
        onChange: function(){
            var g = $('#itemcode').combogrid('grid');	// get datagrid object
            var r = g.datagrid('getSelected');	// get the selected row
            if(r!=null){
                $('#itemname').val(r.itemname);
                $("#itemid").val(r.itemid);
            }
            $('#btnUnitVsItem1').show();
        }
    })
    var isCheck = false;
    var k = 1;

    function fundchange(){
        var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
        var originfund=$("#originfund").val();
        if (!reg.test(originfund)) {
            alert("金额格式不正确");
            return;
        }
        originfund = (parseFloat(originfund)).toFixed(2);
        $("#bigoriginfund").val(upDigit(originfund));
    }

    function pay() {
        var postscript = $("#postscript").val();
        var cantonid = $("#cantonid").val();
        var bankaffirm = $("#bankaffirm").val();
        var paybankdt = $("#paybankdt").val();
        if(cantonid=="") {
            alert("请选择行政区划！");
            $("#cantonid").focus();
            return;
        }
        if(postscript=="") {
            alert("请填写用途说明！");
            $("#postscript").focus();
            return;
        }
        if(bankaffirm=="") {
            alert("请填写交易流水号！");
            $("#bankaffirm").focus();
            return;
        }
        if(paybankdt=="") {
            alert("请填写交易日期！");
            $("#paybankdt").focus();
            return;
        }
        var payer=$("#payer").val();
        var originfund=$("#originfund").val();
        if(payer=="") {
            alert("请输入收款人全称！");
            return;
        }
        if(originfund=="") {
            alert("请输入金额！");
            return;
        }
        if (originfund < 0 || originfund == 0) {
            alert("金额不能为0或负数！");
            return;
        }
        var t = $('#cantoncode').combotree('tree').tree('getSelected');	// get the tree object
        var g = $('#unitcode').combogrid('grid').datagrid('getSelected');	// get datagrid object
        var r = $('#itemcode').combogrid('grid').datagrid('getSelected');	// get datagrid object
        var p = $('#payee').combogrid('grid').datagrid('getSelected');	// get datagrid object
        $('#ChargeBillHandForm').form({
            url: prefix+'/view/waitaffirmpayinfo/saveOtherACview',
            onSubmit:function(param){
                param.bankid =p.bankid;
                param.cantonid=t.id;
                param.itemid =r.itemid;
                param.unitid=g.unitid;
                param.cantoncode=t.acode;
                var isValid = $(this).form('validate');
                if (isValid){
                    $.messager.progress({
                        title: '提示',
                        msg: '数据处理中，请稍候……',
                        text: ''
                    });
                }
                return isValid;
            },
            success:function(data) {
                $.messager.progress('close');
                var data = eval('(' + data + ')');
                if(data.success) {
                    location=prefix+'/view/waitaffirmpayinfo/waitaffirmpayinfoview';
                }
                alert(data.msg);
            }
        });
        $('#ChargeBillHandForm').submit();
    }

    function openfwfcz() {
        $('#itemcode').combogrid('clear');
        $('#itemname').val('');
        $('#btnUnitVsItem1').hide();
    }

</script>
</body>
</html>
